//
//  ACFeedBackInfoViewController.m
//  ACLiteAVUISDK
//
//  Created by 冯琰琰 on 2021/4/1.
//

#import "ACFeedBackInfoViewController.h"

@interface ACFeedBackInfoViewController ()
@property(nonatomic,strong)UILabel *attentionLabel;
@property(nonatomic,strong)UILabel *cautiousLabel;
@property(nonatomic,strong)UILabel *supportLabel;
@end

@implementation ACFeedBackInfoViewController
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self requestData];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    UILabel *label = [[UILabel alloc] init];
    label.text = @"意向";
    label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
    label.textColor = UIColorFromRGB(0x30322C);
    [self.view addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_offset(16);
    }];
    UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [closeBtn setImage:[UIImage imageWithName:@"live_live_close_gray" bundle:ACLiteAVUISDK targetClass:[self class]] forState:UIControlStateNormal];
    [self.view addSubview:closeBtn];
    [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(46, 46));
        make.centerY.equalTo(label.mas_centerY);
    }];
    @weakify(self)
    [[closeBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        @strongify(self)
        [self dismissViewControllerAnimated:YES completion:nil];
    }];
    
    UIView *bgView = [[UIView alloc] init];
    bgView.backgroundColor = UIColorFromRGB(0xFEAFA3);
    bgView.layer.cornerRadius = 4;
    bgView.layer.masksToBounds = YES;
    [self.view addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.height.mas_equalTo(68);
        make.top.equalTo(label.mas_bottom).offset(28);
    }];
    
    UILabel *label_left = [[UILabel alloc] init];
    label_left.text = @"看好";
    label_left.textAlignment = NSTextAlignmentCenter;
    label_left.backgroundColor = UIColorFromRGB(0xFF6048);
    label_left.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
    label_left.textColor = UIColorFromRGB(0xffffff);
    [bgView addSubview:label_left];
    [label_left mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(0);
        make.height.mas_equalTo(40);
        make.width.mas_equalTo((ACSCREEN_WIDTH - 30 - 2) / 3.0 );
    }];
    
    UIView *leftView = [[UIView alloc] init];
    leftView.backgroundColor = UIColorFromRGB(0xFF6048);
    [bgView addSubview:leftView];
    [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.width.mas_equalTo(1);
        make.left.equalTo(label_left.mas_right);
    }];
    
    UILabel *label_center = [[UILabel alloc] init];
    label_center.text = @"持续关注";
    label_center.textAlignment = NSTextAlignmentCenter;
    label_center.backgroundColor = UIColorFromRGB(0xFF6048);
    label_center.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
    label_center.textColor = UIColorFromRGB(0xffffff);
    [bgView addSubview:label_center];
    [label_center mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.height.width.equalTo(label_left);
        make.left.equalTo(leftView.mas_right);
    }];
    
    UIView *rightView = [[UIView alloc] init];
    rightView.backgroundColor = UIColorFromRGB(0xFF6048);
    [bgView addSubview:rightView];
    [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.width.mas_equalTo(1);
        make.left.equalTo(label_center.mas_right);
    }];
    
    UILabel *label_right = [[UILabel alloc] init];
    label_right.text = @"谨慎";
    label_right.textAlignment = NSTextAlignmentCenter;
    label_right.backgroundColor = UIColorFromRGB(0xFF6048);
    label_right.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
    label_right.textColor = UIColorFromRGB(0xffffff);
    [bgView addSubview:label_right];
    [label_right mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.height.width.equalTo(label_left);
        make.left.equalTo(rightView.mas_right);
    }];
    
    
    self.supportLabel = [[UILabel alloc] init];
    self.supportLabel.text = @"0";
    self.supportLabel.textAlignment = NSTextAlignmentCenter;
    self.supportLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
    self.supportLabel.textColor = UIColorFromRGB(0x303133);
    [bgView addSubview:self.supportLabel];
    [self.supportLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(28);
        make.width.centerX.equalTo(label_left);
    }];
    
    self.attentionLabel = [[UILabel alloc] init];
    self.attentionLabel.text = @"0";
    self.attentionLabel.textAlignment = NSTextAlignmentCenter;
    self.attentionLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
    self.attentionLabel.textColor = UIColorFromRGB(0x303133);
    [bgView addSubview:self.attentionLabel];
    [self.attentionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.bottom.equalTo(self.supportLabel);
        make.centerX.equalTo(label_center);
    }];
    
    self.cautiousLabel = [[UILabel alloc] init];
    self.cautiousLabel.text = @"0";
    self.cautiousLabel.textAlignment = NSTextAlignmentCenter;
    self.cautiousLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
    self.cautiousLabel.textColor = UIColorFromRGB(0x303133);
    [bgView addSubview:self.cautiousLabel];
    [self.cautiousLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.bottom.equalTo(self.supportLabel);
        make.centerX.equalTo(label_right);
    }];
}

-(void)requestData{
    [SVProgressHUD showWithStatus:@""];
    [ACLiveRoomManager requestFeedBackInfoWithLiveID:self.liveID success:^(id  _Nonnull responseObject) {
        [SVProgressHUD dismiss];
        DDLogInfo(@"%@",responseObject);
        self.attentionLabel.text =  [[responseObject valueForKey:@"attention"] stringValue];
        self.cautiousLabel.text =  [[responseObject valueForKey:@"cautious"] stringValue];
        self.supportLabel.text =  [[responseObject valueForKey:@"support"] stringValue];
    } failure:^(NSError * _Nonnull error) {
        [SVProgressHUD dismiss];
        [SVProgressHUD showErrorWithStatus:@"网络错误"];
    }];
}
@end
